#ifndef __INCcliArgh
#define __INCcliArgh

#include <cstdio>
#include <map>
#include <vector>
#include <string>
#include <type.h>
#include <validator.h>

namespace cli
{
    struct ParamConfig
    {
        const char *long_name;
        const char *short_name;
        const char *help;
        bool required;
        const char *default_val;
        bool takes_value;
        parser::ValidatorFunc validator;
    };

    struct CliCmd
    {
        const char* name;
        const char* description;
        int         recvId;
        int         cmdId;
        std::vector<ParamConfig> params;
        bool        is_async;
    };

    class Args
    {
    private:
        std::map<std::string, std::string> params_;
        int _sessionId;

    public:
        Args(int sessionId) : _sessionId(sessionId) {}
        Args() : _sessionId(-1) {}
        ~Args(){ setSessionId(-1); }
        int getSessionId() const { return _sessionId; }

        bool has(const std::string& name) const { return params_.find(name) != params_.end(); }
        const std::string& get(const std::string& name) const { return params_.at(name); }
        void set(const std::string& name, const std::string& value) { params_[name] = value; }
        void set_default(const std::string& name, const std::string& default_val) { params_[name] = default_val; }

        int setSessionId(int sessionId){ return _sessionId = sessionId; }
        bool has(const char* name) const;
        const char *get(const char* name) const;
        void set(const char* name, const char* value);
        void set_default(const char* name, const char* default_val);
    };
}

#endif // __INCcliArgh
